<?php
use \Workerman\Autoloader;

require_once __DIR__ . '/../../../../../Workerman/Autoloader.php';
require_once __DIR__.'/../../../Config/Const.php';
Autoloader::setRootPath(__DIR__.'/../../..');

$page_groupId = GROUP_RESTAURANT_MNG;
$page_pageId = PAGE_RESTAURANT_ADD;

require "../framepages/moudle_base.php";


$mode = $_POST['mode'];
$result = 'normal';
if ($mode == 'res_add') {

    $restaurant_name = $_POST['restaurant_name'];
    $contact_name = $_POST['contact_name'];
    $contact_number = $_POST['contact_number'];
    $business_licence_img = $_POST['business_licence_img'];
    $catering_licence_img = $_POST['catering_licence_img'];
    $special_permission_img = $_POST['special_permission_img'];
    $personal_credentials_img = $_POST['personal_credentials_img'];
    $permission_status = $_POST['permission_status'];

    $restaurant_record = new \Data\Restaurant(array());
    $restaurant_record->setRESTAURANT_NAME($restaurant_name);
    $restaurant_record->setCONTACT_NAME($contact_name);
    $restaurant_record->setCONTACT_NUMBER($contact_number);
    $restaurant_id = \Data\Restaurant_DAO::insert($restaurant_record);

    $restaurant_certification_record = new \Data\Restaurant_certification(array());
    $restaurant_certification_record->setRESTAURANT_ID($restaurant_id);
    $restaurant_certification_record->setBUSINESS_LICENCE_IMG($business_licence_img);
    $restaurant_certification_record->setCATERING_LICENCE_IMG($catering_licence_img);
    $restaurant_certification_record->setSPECIAL_PERMISSION_IMG($special_permission_img);
    $restaurant_certification_record->setPERSONAL_CREDENTIALS_IMG($personal_credentials_img);
    $restaurant_certification_record->setPERMMISION_STATUS($permission_status);
    \Data\Restaurant_certification_DAO::insert($restaurant_certification_record);

    $result = 'succ_add_res';
}




?>
<div class="main-content">
    <form method="post" action="">
        <input type="hidden" name="mode" id="mode" value="res_add">
        <table style="border-collapse: separate;border-spacing: 0 10px">
            <tr>
                <td>商铺名称：</td>
                <td><input type="text" id="restaurant_name" name="restaurant_name" ><td>
                <td>联系人：</td>
                <td><input type="text" id="contact_name" name="contact_name" ><td>
            </tr>

            <tr>
                <td>手机号：</td>
                <td><input type="text" id="contact_number" name="contact_number" ><td>
            </tr>
            <tr>
                <td>营业执照：</td>
                <td><input type="file" id="business_licence_img" name="business_licence_img" ><td>
            </tr>
            <tr>
                <td>餐饮许可证：</td>
                <td><input type="file" id="catering_licence_img" name="catering_licence_img" ><td>
            </tr>
            <tr>
                <td>特许证件：</td>
                <td><input type="file" id="special_permission_img" name="special_permission_img" ><td>
            </tr>
            <tr>
                <td>个人证件：</td>
                <td><input type="file" id="personal_credentials_img" name="personal_credentials_img" ><td>
            </tr>
            <tr>
                <td>审核状态：</td>
                <td><input type="radio" id="permission_status" name="permission_status" value="<?php echo PERMISSION_PROCESS ?>" >审核中&nbsp;&nbsp;&nbsp;
                <input type="radio" id="permission_status" name="permission_status" value="<?php echo PERMISSION_SUCCESS ?>" >审核通过&nbsp;&nbsp;&nbsp;
                <input type="radio" id="permission_status" name="permission_status" value="<?php echo PERMISSION_FAIL ?>" >审核未通过<td>
            </tr>

        </table>
        <div class="btn-toolbar list-toolbar">
            <input type="submit" class="btn btn-danger" value="提交">
        </div>
    </form>

    <?php
    require "../framepages/footer.php";
    ?>
</div>
</div>
<script src="../lib/bootstrap/js/bootstrap.js"></script>
<script>
    function init() {
        var msg = '<?php echo $result ?>';
        if (msg == 'succ_add_res') {
            alert('商铺添加成功');
        }
    }
</script>
</body>
</html>